//统一管理所有api
import requests from './request';

//登录请求，返回token
export const reqLogin = (data)=> 
    requests({url:"/login",method:"post",data});

//注销请求
export const reqLogout = () => 
    requests({url:"/logout",method:"post"});

//注册请求
export const reqRegister = (data) => 
    requests({url:"/register",method:"post",data});

//获取验证码请求
export const reqImageVerify = () => requests({ url: "/captcha", method: "get" });

//验证旧密码
export const reqVerifyOldPassword = (data) =>
  requests({ url: `/verify?password=${data}`, method: "post" });

//修改密码
export const reqUpdatePwd = (data) =>
  requests({ url: `/modify?newPassword=${data}`, method: "post" });

//管理员重置密码
export const reqResetPwd = (data) =>
  requests({
    url: `/authority/user/resetPassword?Aid=${data.Aid}&newPassword=${data.newPassword}`,
    method: "post",
  });

//获取所有用户
export const reqAllUser = (data) =>
  requests({
    url: `/authority/user/getAllAdmin?page=${data.page}&pageSize=${data.pageSize}`,
    method: "get",
  });

//查询用户
export const reqSearchUser = (data) =>
  requests({
    url: `/authority/user/queryAdmin/?parameter=${data.parameter}&page=${data.page}&pageSize=${data.pageSize}`,
    method: "get",
  });

//查询当前用户身份信息
export const reqCurrentUserInfo = () =>
  requests({
    url: "/admin/info",
    method: "get",
  });




  //编排比赛
export const reqAlgorithm = (data) => 
    requests({ url: `/arrange/arrangeAlgorithm/${data}`, method: "get",data });

//获取编排结果
export const reqAlgorithmRes = () =>
  requests({ url: "/arrange/getArrangeResult", method: "get" });





//创建一项比赛
export const reqCreateCompetition = (data) =>
  requests({
    url: "/competition/create/addCompetition",
    method: "post",
    data,
  });

//更新一项比赛信息
export const reqUpdateCompetition = (data) =>
  requests({
    url: "/competition/edit/UpdateCompetition",
    method: "post",
    data,
  });

//获取比赛列表（分页）
export const reqCompetitionList = (data) =>
  requests({
    url: `/getAll?PageNum=${data.PageNum}&PageSize=${data.PageSize}`,
    method: "get",
  });

//查询比赛
export const reqSearchCompetition = (data) => 
    requests({ url: `/query?word=${data}`, method: "post" });

//删除比赛
export const reqDeleteCompetition = (data) =>
  requests({
    url: `/competition/edit/deleteCompetition?CName=${data}`,
    method: "post",
    data,
  });
  




//查询所有裁判
export const reqAllJudges = () =>
  requests({
    url: "/authority/judge/findJudgeAll",
    method: "get",
  });

  //修改比赛裁判
export const reqUpdateCompetitionReferee = (data) =>
  requests({
    url: `/authority/judge/updateJudge?Jid=${data.Jid}&CName=${data.CName}`,
    method: "put",
  });

  //分页获取裁判列表
export const reqGetJudgeList = (data) =>
  requests({
    url: `/authority/judge/queryJudge?page=${data.page}&pageSize=${data.pageSize}`,
    method: "get",
  });

//删除裁判
export const reqDeleteJudge = (data) =>
  requests({
    url: `/authority/judge/deleteJudge?Jid=${data}`,
    method: "DELETE",
  });

//添加裁判
export const reqAddJudge = (data) =>
  requests({
    url: `/authority/judge/setJudge?Name=${data.Name}&other=${data.other}&userName=${data.userName}&password=${data.password}&phoneNum=${data.phoneNum}`,
    method: "post",
    data,
  });





//查询参赛者已经参与的比赛数量
export const reqCompetitionPlayerParticipantNum = (data) =>
  requests({ url: `/getSportNum?Pid=${data}`, method: "post" });

//获取所有比赛的参赛者 
export const reqCompetitionPlayerList = () =>
  requests({ url: `/getAllAttendInfo`, method: "post" });

//分页获取所有比赛参赛者
export const reqAllEnrollPlayerList = (PageNum) =>
  requests({ url: `/getAttendInfo_Page?PageNum=${PageNum}`, method: "post" });

//报名某项比赛
export const reqEnrollCompetition = (data) =>
  requests({ url: `/registration/entry/attend`, method: "post", data });

//参赛者注册个人信息
export const reqPlayerInfoUpdate = (data) =>
  requests({ url: `/playLogin`, method: "post", data });

//取消报名
export const reqCancelEnroll = (data) =>
  requests({
    url: `/registration/manage/delSignInfo?PId=${data.PId}&CName=${data.CName}`,
    method: "post",
  });

//获取所有选手信息
export const reqAllPlayerInfo = () => 
  requests({ url: `/getPlayer`, method: "get" });

//根据Pid获取选手报名项目
export const reqPLayerEnrollComp = (data) =>
  requests({ url: `/getSignInfo?Pid=${data}`, method: "post" });

//选手查询个人信息
export const reqGetUserInfo = () =>
  requests({ url: `/getNowUserInfo`, method: "post" });

//更新选手个人信息（只有学校）
export const reqUpdateUserInfo = (data) =>
  requests({ url: `/playerUpdate?school=${data}`, method: "post" });

//更新成绩
export const reqUpdateScore = (data) =>
  requests({
    url: `/schedule/grade/updateScore`,
    method: "post",
    data,
  });



//查询所有人成绩
export const reqAllPlayerScore = (data) =>
  requests({ 
    url: `/playcompetition/findAll?page=${data.page}&pageSize=${data.pageSize}`,
    method: "get",
  });

//根据比赛查询所有人成绩
export const reqAllPlayerScoreByCompetition = (data) =>
  requests({
    url: `/playcompetition/findAllByCompetition?page=${data.page}&pageSize=${data.pageSize}`,
    method: "get",
    data,
  });

//根据选手id查询成绩
export const reqGetOwnScores = (data) => 
  requests({ url: `/playcompetition/getID/${data}`,method:"get" });



//获取所有文件
export const reqGetFileList = (data) =>
  requests({
    url: `/program/findAll?page=${data.page}&pageSize=${data.pageSize}`,
    method: "get",
    data,
  });

//搜索文件
export const reqSearchFile = (data) =>
  requests({ url: `/program/findFileByDim?name=${data}`, method: "get" });

//下载文件
export const reqdownloadFile = (data) =>
  requests({ 
    url: `/download?fileName=${data}`, 
    method: "post", 
  });

//删除文件
export const reqDelFile = (data) =>
  requests({ url: `/program/delFile?filename=${data}`, method: "delete" });



//分页获取公告
export const reqGetNoticeList = (data) =>
  requests({
    url: `/message/queryMessage?page=${data.page}&pageSize=${data.pageSize}`,
    method: "get",
  });

//管理员添加公告
export const reqSetNotice = (data) =>
  requests({
    url: `/message/setMessage?Title=${data.addNotice.articleTitle}&Content=${data.addNotice.comment}&Publish_date=${data.createTime._value}`,
    method: "post",
  });

// 更新菜单
export const reqUpdateMenuRole = (data) =>{
  requests({
    url: `/authority/menu/updateMenuRole`,
    method: "post",
    data,
  });
}

//获取菜单
export const reqAllMenu = () =>
  requests({ url: `/authority/menu/menus`, method: "get" });
  
// 获取所有角色
export const reqAllRole = () =>
  requests({ url: `/authority/menu/getAllRole`, method: "get" });

//获取某一角色菜单
export const reqRoleMenu = (data) =>
  requests({ url: `/authority/menu/mid/${data}`, method: "get" });

//根据用户id查询菜单
export const reqMyMenu = (data) =>
  requests({
    url: `/system/menu`,
    method: "get",
  });

//增加角色
export const reqAddRole = (data) =>
  requests({ url: `/authority/menu/addRole`, method: "post", data });